﻿using AutoMapper;
using Management.Systeam.Domaina;
using Management.Systeam.ErrorCode;
using Management.Systeam.Infrastructure.Interface;
using Management.Systeam.Read.Apis.Application.Command.Useres;
using MediatR;

namespace Management.Systeam.Read.Apis.Application.CommandHandler.Useres
{
    public class FistUsersCommandHandler : IRequestHandler<FistUsersCommand, ApiResult<Users>>
    {
        IBaseRepository<Users> Users;
        IMapper mapper;
        public FistUsersCommandHandler(IBaseRepository<Users> Users, IMapper mapper)
        {
            this.Users = Users;
            this.mapper = mapper;

        }

        public async Task<ApiResult<Users>> Handle(FistUsersCommand request, CancellationToken cancellationToken)
        {
           var list=  Users.GetQuery().Where(c=>c.UId == request.Id).First();
            return new ApiResult<Users> 
            {
                Code=ApiEnum.success,
               Message="获取成功",
               Data=list
            };
        }
    }
}
